package MyThread;

import com.sun.xml.internal.bind.v2.model.annotation.RuntimeAnnotationReader;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * user:likaihang
 * Date:2022-12-04
 * Time:17:53
 */
class MyThread extends Thread {
    @Override
    public void run() {
        System.out.println("haha");
    }
}
class MyRunnable implements Runnable{

    @Override
    public void run() {
        System.out.println("haha");
    }
}
public class MyThreadDemo1 {
//    //重写Thread方法
//    public static void main(String[] args) {
//        Thread t=new MyThread();
//        t.start();
//    }
//    //继承Runnable
//    public static void main(String[] args) {
//        Runnable runnable=new MyRunnable();
//        Thread t=new Thread(runnable);
//        t.start();
//    }
    //内部类继承Thread
//    public static void main(String[] args) {
//        Thread t=new Thread(){
//            @Override
//            public void run() {
//                System.out.println("haha");
//            }
//        };
//        t.start();
//    }
    //匿名内部类实现Runable接口
//    public static void main(String[] args) {
//        Thread t=new Thread(new Runnable() {
//            @Override
//            public void run() {
//                System.out.println("haha");
//            }
//        });
//        t.start();
//    }
    //lambda表达式
    public static void main(String[] args) {
        Thread t=new Thread(()->{
            System.out.println("haha");
        });
        t.start();
    }
}
